import { _decorator, Component, Node, Input, SpriteFrame, Sprite } from 'cc';
import { AudioMgr } from './tool/AudioMgr';
const { ccclass, property } = _decorator;

@ccclass('AudioControl')
export class AudioControl extends Component {
    
    @property(SpriteFrame)
    voiceMute:SpriteFrame
    @property(SpriteFrame)
    voiceUnmute:SpriteFrame
    
    
    start() {

        this.node.on(Input.EventType.TOUCH_START, this.switchAudio, this)

    }

    update(deltaTime: number) {
        
    }


    switchAudio() {
        if(AudioMgr.inst.audioSource.playing) {
            AudioMgr.inst.pause()
            this.node.getComponent(Sprite).spriteFrame = this.voiceUnmute
        }else{
            AudioMgr.inst.resume()
            this.node.getComponent(Sprite).spriteFrame = this.voiceMute
        }
    }



}


